package fourzerofour.guoshixu.day01;

import java.util.Scanner;

public class Question5 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //用户输入的数
        int num;
        do{
            System.out.println("请输入一个3位数：");
            num = scanner.nextInt();
        }while (num>999||num<100);

         //定义一个最大数
        int max = 0;
        //定义最大数对应的位数
        String posation = "";
        //拆分用户输入的数
        //个位
        int unit = num %10;
        //十位
        int ten = num %100 / 10;
        //百位
        int hundred = num / 100;
        if(unit > max){
            max = unit;
            posation = "个位";
        }
        if(ten>max){
            max = ten;
            posation = "十位";
        }
        if(hundred>max){
            max = hundred;
            posation = "百位";
        }

        System.out.println("您输入的数字为：" + num + ",其中个位为" + unit + ",十位为" + ten + ",百位为" + hundred
            + ",所以最大值在" + posation + ",值为" + max
        );
    }
}
